import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import TreeTable from 'vue-table-with-tree-grid'
// 导入全局样式表
import './assets/css/global.css'
// 导入第三方图标
import './assets/font_vx58sk269cr/iconfont.css'
import './assets/font_menu/iconfont.css'
Vue.config.productionTip = false

Vue.use(ElementUI);
Vue.component('tree-table', TreeTable);
// 配置请求的根路径
axios.defaults.baseURL='https://lianghj.top:8888/api/private/v1/'


// token令牌**通过axios请求拦截器添加token ,保证拥有获取数据的权限
axios.interceptors.request.use(config=>{
  // console.log(config); 这里是测试Authorization是否有效
  // ，请求对象，添加token验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token');
  // token令牌**最后必须return**
  return config;
})
// 时间过滤器
Vue.filter('dateFormat', function (originVal) {
  const dt = new Date(originVal)

  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  // yyyy-mm-dd hh:mm:ss
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.prototype.$http =axios

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
